package com.flong.lambda;

import com.alibaba.fastjson.JSON;
import org.junit.Test;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author:liangjl
 * @Date: 2020/6/20-20:02
 * @Eamil:jilongliang@sina.com
 * @Description:
 */
public class Test7 {

    @Test
    public void test1(){
        List<String> list = new ArrayList<>();

        Collections.addAll(list,"一灯大师","周伯通","张三丰","瑛姑","小龙女","黄蓉");

        List<String> zlist = list.stream().filter(str -> str.contains("张")).collect(Collectors.toList());
        System.out.println(JSON.toJSON(zlist));


        long zcount = list.stream().filter(str -> str.contains("张")).count();
        System.out.println(zcount);

    }

}
